<?php

class Application_Model_Usuario extends Sgit_Model
{  
    protected $_name = 'usuarios';
    protected $_primary = 'id';
    protected $_cache_activa = TRUE;

    public function getUsuario($values)
    {
        
        //permite pasar unico parametro id del contador
        if(is_numeric($values)){
            $id=$values;unset($values);$values['id']=$id;unset($id);
        } 
        
        $select=$this->getAdapter()->select()->from(array($this->_name));
         

        if (is_array($values['id']) || is_numeric($values['id']))
            $select->where("{$this->_name}.id IN (?)", $values['id']);
        
        
        if(is_numeric($values['estado']))
            $select->where("{$this->_name}.estado= ?", $values['estado'],INTEGER);
  
  
        $select->where("{$this->_name}.id != ?", 0,INTEGER);
  
      
        $rows = $this->getAdapter()->fetchAll($select);
        
        
        $m_AclGroup=new Application_Model_AclGroup();
        
        foreach($rows as &$v )
        {
            $v['estado'] =Sgit_Util_SiNo::run($v['estado']);
            $v['grupos'] =$m_AclGroup->getGrupoByIdUser($v['id']);
        }


        if (is_numeric($values['id']))
            return $rows[0];
        else
            return $rows;
    }



}  




